package orchestration.businessprocess.model.nodes;

import java.util.Set;

import orchestration.businessprocess.model.BPArtifact;
import orchestration.businessprocess.model.BPNodeId;
import orchestration.businessprocess.model.IBPVisitor;


/**
 * A task represent an operation or a set of related operation that must be
 * executed
 * It can have a loopingExpression to define a condition that must be
 * checked before going to next node in the visit
 * @author  <a href="mailto:car.ferrarini@gmail.com">Carlo Ferrarini</a>
 */
public class BPTask extends BPNode {

	/**
	 * @uml.property  name="next"
	 * @uml.associationEnd  
	 */
	private BPNode next;
	/**
	 * @uml.property  name="loopingExpression"
	 */
	private String loopingExpression;
	
	BPTask(BPNodeId id,Set<BPArtifact> input,Set<BPArtifact> output,BPNode next) {
		super(id,BPNode.NODE_TYPE_TASK,input,output);
		this.next=next;
	}

	public BPTask(BPNodeId id, Set<BPArtifact> input, Set<BPArtifact> output) {
		super(id, BPNode.NODE_TYPE_TASK,input,output);
	}

	@Override
	public void accept(IBPVisitor visitor) {
		visitor.visit(this);
	}

	/**
	 * @return
	 * @uml.property  name="next"
	 */
	public BPNode getNext() {
		return next;
	}
	/**
	 * @param next
	 * @uml.property  name="next"
	 */
	public void setNext(BPNode next) {
		this.next = next;
	}

	/**
	 * @param loopingExpression
	 * @uml.property  name="loopingExpression"
	 */
	public void setLoopingExpression(String loopingExpression) {
		this.loopingExpression = loopingExpression;
	}

	/**
	 * @return
	 * @uml.property  name="loopingExpression"
	 */
	public String getLoopingExpression() {
		return loopingExpression;
	}
	
	public boolean isLooping(){
		return ( loopingExpression!=null && !loopingExpression.equals("") ) ;
	}
	

}
